﻿using PostRequestFactory.Core.Parameters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text;
using PostRequestFactory.Core;

namespace PostRequestFactory.UnitTests
{
    
    /// <summary>
    ///This is a test class for BasicRequestParameterTest and is intended
    ///to contain all BasicRequestParameterTest Unit Tests
    ///</summary>
    [TestClass()]
    public class BasicRequestParameterTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for BasicRequestParameter Constructor
        ///</summary>
        [TestMethod()]
        public void BasicRequestParameterConstructorTest()
        {
            string name = "TestName";
            string content = "AbcȘaBc";
            Encoding currentContentEncoding = Encoding.UTF8;
            var request = new BasicRequestParameter(name, content, currentContentEncoding);

            Assert.AreEqual("TestName",request.Name,"Incorrect Name initialization.");
            Assert.AreEqual("Abc%c8%98aBc", request.Content, "Incorrect url encoded content.");
        }

        /// <summary>
        ///A test for ContentDisposition
        ///</summary>
        [TestMethod()]
        public void ContentDispositionTest()
        {
            var request = new BasicRequestParameter("TestName", "test");
           
            Assert.AreEqual("form-data",request.ContentDisposition,"BasicParameter should always have content-disposition equals with 'form-data'.");
        }

        /// <summary>
        ///A test for ContentType
        ///</summary>
        [TestMethod()]
        public void ContentTypeTest()
        {
            var request = new BasicRequestParameter("TestName", "test");

            Assert.AreEqual("application/x-www-form-urlencoded", request.ContentType, "BasicParameter should always have content-type equals with 'application/x-www-form-urlencoded'.");
        }

        /// <summary>
        ///A test for ParameterType
        ///</summary>
        [TestMethod()]
        public void ParameterTypeTest()
        {
            var request = new BasicRequestParameter("TestName", "test");

            Assert.AreEqual(RequestParameterType.Basic, request.ParameterType, "BasicParameter should be of type 'RequestParameterType.Basic'.");
        }
    }
}
